package com.spring.boot.springBoot.controller;

import com.spring.boot.springBoot.entity.UserDemo;
import com.spring.boot.springBoot.service.UserDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by pactera on 2017/9/27.
 */
@RestController
@RequestMapping("/user")
public class UserDemoController {


    @Autowired
    private UserDemoService userDemoService;


    @GetMapping("/")
    public UserDemo save(){
        UserDemo userDemo = new UserDemo();
        userDemo.setName("name");
        userDemo.setBirthday(new Date());
        userDemo.setSex(0);
        userDemoService.save(userDemo);
        return userDemo;
    }

    @GetMapping("/find")
    public UserDemo getById(){
        return userDemoService.getById(1);
    }

}
